package top.hkyzf.study.leetcode.string;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 朱峰
 * @date 2022-2-10 9:03
 */
public class 最简分数_1447 {
    public List<String> simplifiedFractions(int n) {
        List<String> result = new ArrayList<>();
        for (int i = 1; i < n; i++) {
            for (int j = i+1; j <= n; j++) {
                if (gcd(i, j) == 1) {
                    result.add(i + "/" + j);
                }
            }
        }
        return result;
    }

    private int gcd(int i, int j) {
        if (j == 0) {
            return i;
        }
        return gcd(j, i%j);
    }

    @Test
    public void testSimplifiedFractions () {
        int n = 1;
        System.out.println(simplifiedFractions(n));
    }
}
